left
详情
主题:Hibernate 错误解决 返回 搜索

1.org.hibernate.NonUniqueObjectException: a different object with the.


解决:


<id name="id">
     <column name="id" sql-type="int(11)"/>
     <generator class="native"/>   //加上自动生成
</id>




2.org.hibernate.AssertionFailure: null id in com.base.program.entity.Program entry (don't flush the Session after an except)


解决:


字段不够长,给ID指定长度

@Id
@Column(name = "id", nullable = false,length = 11)
@GeneratedValue(strategy=GenerationType.AUTO)
private int id;




3.org.hibernate.engine.jndi.JndiException: Error parsing JNDI name


去掉hibernate.cfg.xml里的 name 属性



javax.persistence.PersistenceException: org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of cc.www.hibernateproject.model.Student.fenshu


解决方法1:该bean 中相应字段int 改为Integer

解决方法2:数据库中相应字段默认不为null

警告:
您是否确定删除贴子?
确定 取消
copyright